/*
 * $Id: ip_var.h,v 1.3 1993/06/30 05:45:25 jraja Exp $
 *
 * HISTORY
 * $Log: ip_var.h,v $
 * Revision 1.3  1993/06/30  05:45:25  jraja
 * Changed bitfield definitions to be more like ANSI-C.
 *
 * Revision 1.2  1993/03/03  21:35:28  jraja
 * Moved data definitions to ip_input.c.
 *
 * Revision 1.1  92/11/17  16:29:56  16:29:56  jraja (Jarno Tapio Rajahalme)
 * Initial revision
 * 
 *
 */

/*
 * Copyright (c) 1982, 1986 Regents of the University of California.
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 * 3. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgement:
 *      This product includes software developed by the University of
 *      California, Berkeley and its contributors.
 * 4. Neither the name of the University nor the names of its contributors
 *    may be used to endorse or promote products derived from this software
 *    without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 *
 *      @(#)ip_var.h    7.7 (Berkeley) 6/28/90
 */

/*
 * Overlay for ip header used by other protocols (tcp, udp).
 */
OBJECT ipovly
    ih_next:PTR TO BYTE,
    ih_prev:PTR TO BYTE,       /* for protocol sequence q's */
    ih_x1:UBYTE,                  /* (unused) */
    ih_pr:UBYTE,                  /* protocol */
    ih_len:WORD,                 /* protocol length */
    ih_src:in_addr,         /* source internet address */
    ih_dst:in_addr         /* destination internet address */


/*
 * Ip reassembly queue structure.  Each fragment
 * being reassembled is attached to one of these structures.
 * They are timed out after ipq_ttl drops to 0, and may also
 * be reclaimed if memory becomes tight.
 */
OBJECT ipq
    next:PTR TO ipq,
    prev:PTR TO ipq,        /* to other reass headers */
    ipq_ttl:UBYTE,                /* time for reass q to live */
    ipq_p:UBYTE,                  /* protocol of this fragment */
    ipq_id:UWORD,                 /* sequence id for reassembly */
    ipq_next:PTR TO ipasfrag,
    ipq_prev:PTR TO ipasfrag,
    ipq_src:in_addr,
    ipq_dst:in_addr


/*
 * Ip header, when holding a fragment.
 *
 * Note: ipf_next must be at same offset as ipq_next above
 */
OBJECT ipasfrag
    ip_v:UBYTE,
    ip_hl:UBYTE,
    ipf_mff:UBYTE,                /* copied from (ip_off&IP_MF) */
    ip_len:WORD,
    ip_id:UWORD,
    ip_off:WORD,
    ip_ttl:UBYTE,
    ip_p:UBYTE,
    ip_sum:UWORD,
    ipf_next:PTR TO ipasfrag,     /* next fragment */
    ipf_prev:PTR TO ipasfrag     /* previous fragment */


/*
 * Structure stored in mbuf in inpcb.ip_options
 * and passed to ip_output when ip options are in use.
 * The actual length of the options (including ipopt_dst)
 * is in m_len.
 */
#define MAX_IPOPTLEN    40

OBJECT ipoption
    ipopt_dst:in_addr,      /* first-hop dst if source routed */
    ipopt_list[MAX_IPOPTLEN]:BYTE       /* options proper */


OBJECT ipstat
    ips_total:LONG,              /* total packets received */
    ips_badsum:LONG,             /* checksum bad */
    ips_tooshort:LONG,           /* packet too short */
    ips_toosmall:LONG,           /* not enough data */
    ips_badhlen:LONG,            /* ip header length < data size */
    ips_badlen:LONG,             /* ip length < ip header length */
    ips_fragments:LONG,          /* fragments received */
    ips_fragdropped:LONG,        /* frags dropped (dups, out of space) */
    ips_fragtimeout:LONG,        /* fragments timed out */
    ips_forward:LONG,            /* packets forwarded */
    ips_cantforward:LONG,        /* packets rcvd for unreachable dest */
    ips_redirectsent:LONG,       /* packets forwarded on same net */
    ips_noproto:LONG,            /* unknown or unsupported protocol */
    ips_delivered:LONG,          /* packets consumed here */
    ips_localou:LONG,           /* total ip packets generated here */
    ips_odropped:LONG,           /* lost packets due to nobufs, etc. */
    ips_reassembled:LONG,        /* total packets reassembled ok */
    ips_fragmented:LONG,         /* output packets fragmented ok */
    ips_ofragments:LONG,         /* output fragments created */
    ips_cantfrag:LONG           /* don't fragment flag was set, etc. */


/* flags passed to ip_output as last parameter */
#define IP_FORWARDING           $1             /* most of ip header exists */
#define IP_ROUTETOIF            SO_DONTROUTE    /* bypass routing tables */
#define IP_ALLOWBROADCAST       SO_BROADCAST    /* can send broadcast packets */

/*
 * definitions moved to ip_input.c
 */
/*
extern struct   ipstat  ipstat;
extern struct   ipq     ipq;                    /* ip reass. queue */
extern u_short  ip_id;                          /* ip packet ctr, for ids */

struct  mbuf *ip_srcroute(void);
*/


